<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>项目详情</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/main.css" />
		<style>
			.media-img {
				/*background-image: url(../images/cbd.jpg);*/
				height: 40vw;
			}
			
			.mui-card-footer {
				background: #FFFFFF;
			}
			
			.mui-card {
				margin: 0;
				box-shadow: none;
				margin-bottom: 4px;
			}
			
			.mui-content>.mui-card:first-child {
				margin-top: 0;
			}
			
			.mui-card-header:before {
				position: absolute;
				top: 0;
				right: 0;
				left: 0;
				height: 1px;
				content: '';
				-webkit-transform: scaleY(.5);
				transform: scaleY(.5);
				background-color: #c8c7cc;
			}
			
			.middle {
				text-align: center;
				justify-content: center;
			}
			
			table.gridtable {
				font-family: verdana, arial, sans-serif;
				font-size: 11px;
				color: #333333;
				border-width: 1px;
				border-color: #666666;
				border-collapse: collapse;
				width: 100%;
				text-align: center;
			}
			
			table.gridtable th {
				border-width: 1px;
				padding: 8px;
				border-style: solid;
				border-color: #666666;
				background-color: #dedede;
			}
			
			table.gridtable td {
				border-width: 1px;
				padding: 8px;
				border-style: solid;
				border-color: #D9D9D9;
				background-color: #ffffff;
			}
			
			.mui-control-content .mui-loading {
				margin-top: 50px;
			}
			
			.jiage-footer:before {
				height: 0;
			}
			.jiage-footer{
				color: #FF9E0D;
				height: 30px;
			}
			
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">项目详情</h1>
		</header>

		<div class="mui-content">
			<div class="mui-scroll">
				<div class="mui-loading">
					<div class="item1_1">
					</div>
				</div>
			</div>

		</div>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/xiangyingshi.js"></script>
		<script type="text/javascript" src="../js/jquery-3.1.1.js"></script>
		<script type="text/javascript" src="../js/constants.js"></script>
		<script type="text/javascript" src="../js/arttmpl.js"></script>
		
		
		<script type="text/javascript" src="../js/qs/md5/md5.min.js" ></script>
		<script type="text/javascript" src="../js/qs/qs.feedback.js" ></script>
		
		<script>
			var html = '';
			var item_name_xiangqing = '',
				item_name_id = '',
				isDrugs = '',
				biaoshi = '',
				yihuid = '',
				higherprice = '',
				ishigherprice = '';
			var panduanJSON = {};
			var priceJSON = [];
			var beipinJSON = [];
			if(mui.os.ios || mui.os.ipad || mui.os.iphone) {
				mui.plusReady(function() {
					var self = plus.webview.currentWebview();
					biaoshi = self.biaoshi;
					yihuid = self.yihuid;
					if(plus.navigator.isImmersedStatusbar()) { // 兼容immersed状态栏模式
						topoffset = (Math.round(plus.navigator.getStatusbarHeight()) + 45) + 'px';
						document.querySelector("header").style.height = topoffset;
						document.querySelector("header").style.paddingTop = "20px";
						document.querySelector(".mui-bar-nav~.mui-content").style.paddingTop = topoffset;
					}

					// 加载完毕后关闭等待框，并展示页面
					var currentView = plus.webview.currentWebview();
					currentView.show('slide-in-right', 200);
					plus.nativeUI.closeWaiting();

					window.addEventListener('sevice_item_xiangqing', function(e) {
						$(".mui-title").html(e.detail.ITEM_NAME);
						item_name_xiangqing = e.detail.ITEM_NAME;
						item_name_id = e.detail.ITEM_NAME_ID;
						var url = serverAddress + "/api/item/appitemdetails/" + item_name_id;
						var item1 = document.querySelector(".mui-content");
						var success = function(data) {
							console.log("项目详情" + JSON.stringify(data));
							isDrugs = data.data.isneeddrugs;
							isneedspares = data.data.isneedspares;
							//"isneeddrugs" : "1", 是否需要药品   0-需要 ;1不
							//isneedrecipe: {type: Boolean, default: false}, //是否需要上传处方
							//isneedadvice: {type: Boolean, default: false}, //是否需要上传医嘱
							//isneedphoto: {type: Boolean, default: false}, //是否需要上传影像
							//isneedenvironmen: {type: Boolean, default: false}, //是否需要上传居住环境

							isneedrecipe = data.data.isneedrecipe;
							isneedadvice = data.data.isneedadvice;
							isneedphoto = data.data.isneedphoto;
							isneedenvironmen = data.data.isneedenvironmen;
							higherprice = data.data.higherprice;
							ishigherprice = data.data.ishigherprice;
							panduanJSON = {
								isDrugs: isDrugs,
								isneedspares: isneedspares,
								isneedrecipe: isneedrecipe,
								isneedadvice: isneedadvice,
								isneedphoto: isneedphoto,
								isneedenvironmen: isneedenvironmen,
								higherprice: higherprice,
								ishigherprice: ishigherprice
							}
							beipinJSON = data.data.sparesgroupid;
							var html2 = '';
							//服务器返回响应，根据响应结果，分析是否登录成功；
							priceJSON = [{
								price: data.data.price,
								times: 1
							}];
							for(var i=0;i<priceJSON.length;i++){
								html2 += priceJSON[i].price + "元/" + priceJSON[i].times+"次";
							}
							if(item1.querySelector('.mui-loading')) {
								html = '<div class="mui-card"><div class="media-img"><img class="qs-img-lazyload" src="' + serverAddress + '/' + data.data.cover + '" data-lazyload="'+serverAddress + '/' + data.data.cover+'"></div><div class="mui-card-footer jiage-footer"><img src="../images/jiage.png" height="30px" style="display:block"><span style="margin-right:55%">价格：' + html2 + ' </span></div></div><div class="mui-card"><div class="mui-card-header">适合人群：</div><div class="mui-card-content"><div class="mui-card-content-inner">' + data.data.crowd + '</div></div><div class="mui-card-header">用户须知：</div><div class="mui-card-content"><div class="mui-card-content-inner">' + formatHttpStringHc(data.data.notice) + '</div></div></div><div class="mui-content-padded"><button id="xiadan" class="mui-btn mui-btn-block mui-btn-warning" type="submit">立即预约</button></div>'
								$(".item1_1").html(html);
							}
						};
						commonHttpUtils(url, "get", {}, success, error, true);
					});
				});
			} else {
				window.addEventListener('sevice_item_xiangqing', function(e) {
					$(".mui-title").html(e.detail.ITEM_NAME);
					item_name_xiangqing = e.detail.ITEM_NAME;
					item_name_id = e.detail.ITEM_NAME_ID;
				});
				mui.plusReady(function() {
					var self = plus.webview.currentWebview();
					biaoshi = self.biaoshi;
					yihuid = self.yihuid;
					if(plus.navigator.isImmersedStatusbar()) { // 兼容immersed状态栏模式
						// 获取状态栏高度并根据业务需求处理，这里重新计算了子窗口的偏移位置
						topoffset = (Math.round(plus.navigator.getStatusbarHeight()) + 45) + 'px';
						document.querySelector("header").style.height = topoffset;
						document.querySelector("header").style.paddingTop = "20px";
						document.querySelector(".mui-bar-nav~.mui-content").style.paddingTop = topoffset;
					}
					// 加载完毕后关闭等待框，并展示页面
					var currentView = plus.webview.currentWebview();
					currentView.show('slide-in-right', 300);
					plus.nativeUI.closeWaiting();
					var url = serverAddress + "/api/item/appitemdetails/" + item_name_id;
					var item1 = document.querySelector(".mui-content");
					var success = function(data) {
						//console.log("详情" + JSON.stringify(data));
						isDrugs = data.data.isneeddrugs;
						isneedspares = data.data.isneedspares;
						//"isneeddrugs" : "1", 是否需要药品   0-需要 ;1不
						//isneedrecipe: {type: Boolean, default: false}, //是否需要上传处方
						//isneedadvice: {type: Boolean, default: false}, //是否需要上传医嘱
						//isneedphoto: {type: Boolean, default: false}, //是否需要上传影像
						//isneedenvironmen: {type: Boolean, default: false}, //是否需要上传居住环境

						isneedrecipe = data.data.isneedrecipe;
						isneedadvice = data.data.isneedadvice;
						isneedphoto = data.data.isneedphoto;
						isneedenvironmen = data.data.isneedenvironmen;
						higherprice = data.data.higherprice;
						ishigherprice = data.data.ishigherprice;
						panduanJSON = {
							isDrugs: isDrugs,
							isneedspares: isneedspares,
							isneedrecipe: isneedrecipe,
							isneedadvice: isneedadvice,
							isneedphoto: isneedphoto,
							isneedenvironmen: isneedenvironmen,
							higherprice: higherprice,
							ishigherprice: ishigherprice
						}
						beipinJSON = data.data.sparesgroupid;
						var html2 = '';
						//服务器返回响应，根据响应结果，分析是否登录成功；
						priceJSON = [{
							price: data.data.price,
							times: 1
						}];
						for(var i=0;i<priceJSON.length;i++){
							html2 += priceJSON[i].price + "元/" + priceJSON[i].times+"次";
						}
						if(item1.querySelector('.mui-loading')) {
							html = '<div class="mui-card"><div class="media-img"><img class="qs-img-lazyload" src="' + serverAddress + '/' + data.data.cover + '" data-lazyload="'+serverAddress + '/' + data.data.cover+'"></div><div class="mui-card-footer jiage-footer"><img src="../images/jiage.png" height="30px" style="display:block"><span style="margin-right:55%">价格：' + html2 + ' </span></div></div><div class="mui-card"><div class="mui-card-header">适合人群：</div><div class="mui-card-content"><div class="mui-card-content-inner">' + data.data.crowd + '</div></div><div class="mui-card-header">用户须知：</div><div class="mui-card-content"><div class="mui-card-content-inner">' + formatHttpStringHc(data.data.notice) + '</div></div></div><div class="mui-content-padded"><button id="xiadan" class="mui-btn mui-btn-block mui-btn-warning" type="submit">立即预约</button></div>'
							$(".item1_1").html(html);
						}
					};
					commonHttpUtils(url, "get", {}, success, error, true);
				});

			}

			mui(".item1_1").on("tap", "button", function(e) {
				//$("#xiadan").addClass("mui-disabled");
				
				if(localStorage.getItem("TOKENID") == null) {
					mui.openWindow({
						url: "../login/login.html"
					});
					return false;
				}
				
				
				var id = localStorage.getItem("TOKENID");
				var head_photo = localStorage.getItem('HEAD_PHOTO');
				var gerenname = localStorage.getItem("GEREN_NAME");
				var hospital = localStorage.getItem("hospital");
				var isshiminghoutai = " ";
				var success = function(data) {
					if(data.result == "success") {
						//是否实名认证
						isshiminghoutai = data.data.idapprove;
						//后台审核实名认证成功与否
						if(isshiminghoutai == "2") {
							mui.openWindow({
								id: 'a04_place_order.html',
								url: '../order/a04_place_order.html',
								show: {
									autoShow: false, //页面loaded事件发生后自动显示，默认为true
									event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
								},
								waiting: {
									autoShow: true //自动显示等待框，默认为true
								},
								extras: {
									ITEM_NAME: item_name_xiangqing,
									ITEM_ID: item_name_id,
									BIAOSHI: biaoshi,
									YIHU_ID: yihuid,
									PANDUAN_JSON: panduanJSON,
									BEIPIN_JSON: beipinJSON,
									PRICE_JSON:priceJSON
								}
							});
							var sevice_item_xiangqing = plus.webview.getWebviewById('a04_place_order.html');
							sevice_item_xiangqing.addEventListener('loaded', function() {
								mui.fire(sevice_item_xiangqing, "sevice_item_xiangqing", {
									ITEM_NAME: item_name_xiangqing,
									ITEM_ID: item_name_id,
									BIAOSHI: biaoshi,
									YIHU_ID: yihuid,
									PANDUAN_JSON: panduanJSON,
									BEIPIN_JSON: beipinJSON,
									PRICE_JSON:priceJSON
								});
							});
						} else if(isshiminghoutai == "1") {
							mui.toast("等待后台审核通过后再进行下单！");
							return false;
						} else {
							mui.toast("请耐心等待后台实名认证审核通过后再进行下单操作");
							mui.openWindow({
								url: "../geren_message/d02_geren_message.html",
								id: "d02_geren_message.html"
							});
							return false;
						}
					}
				};
				var url = serverAddress + "/api/patient/getmyinfo/" + id;
				commonHttpUtils(url, "get", {}, success, error, true);
			})

			

		</script>
	</body>

</html>